//
//  MineViewController.m
//  XingRun
//
//  Created by 赵颜彬 on 17/1/11.
//  Copyright © 2017年 赵颜彬. All rights reserved.
//

#import "MineViewController.h"

@interface MineViewController ()<UITableViewDelegate, UITableViewDataSource>

@property(nonatomic, strong)UITableView *tableView;

@property(nonatomic, strong)NSArray *dataArr;
@end

@implementation MineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"我的";
    
    self.dataArr = @[@"骑行记录",@"星豆",@"收藏",@"设置",@"意见反馈"];
    
    [self cretableView];
    
    //右侧
    UIButton *releaseButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [releaseButton setTitle:@"新增" forState:UIControlStateNormal];
    [releaseButton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
    
    [releaseButton addTarget:self action:@selector(releaseInfo:) forControlEvents:UIControlEventTouchUpInside];
    releaseButton.frame = CGRectMake(0, 0, 40, 30);
    
    UIBarButtonItem *releaseButtonItem = [[UIBarButtonItem alloc] initWithCustomView:releaseButton];
    self.navigationItem.rightBarButtonItem = releaseButtonItem;
    


}
-(void)releaseInfo:(UIButton *)btn{
    LoginViewController *vc = [[LoginViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
}
-(void)cretableView{
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStyleGrouped];
    [self.view addSubview:_tableView];
    _tableView.tableHeaderView = [[MineHeadView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 200 * HEIGHT)];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    UIImageView *img= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"箭头"]];
    img.frame = CGRectMake(350 * WIDTH, 10 * HEIGHT, 8 * WIDTH, 16 * HEIGHT);
    cell.textLabel.text = _dataArr[indexPath.row];
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:14];

    [cell addSubview:img];

    cell.selectionStyle=UITableViewCellSelectionStyleNone;//设置
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50 * HEIGHT;
}

//点
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        QiXingViewController *vc = [[QiXingViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }if (indexPath.row == 1) {
        XingDouViewController *vc = [[XingDouViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 2) {
        ShouCangViewController *vc = [[ShouCangViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }if (indexPath.row == 3) {
        SheZhiViewController *vc = [[SheZhiViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
